home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 22
/
Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso
/
Aminet
/
biz
/
dbase
/
db.lha
/
Examples
/
ARexxDemos
/
ExpandII.db
< prev
next >
Wrap
Text File
|
1994-09-25
|
2KB
|
74 lines
/* Rexxprogram for db that expands some shortcuts */
/* This one opens a file with 'aliases', one per line, the first word */
/* being the word to expand, and the rest of the line being what to */
/* expand into */
/* User may enter one or more words to expand in one field */
Options Results
GETFIELD
shortwords = result
expwords = ''
if word(shortwords,1) = '+' then do
call delete_word(word(shortwords,2))
if open('file', 'expandwordlist', Append) then do
nil = writeln('file', subword(shortwords,2))
nil = close('file')
exit
end
end
if word(shortwords,1) = '-' then do
call delete_word(word(shortwords,2))
exit
end
do i = 1 to words(shortwords)
shortword = word(shortwords, i)
found = 'no'
if open('file', 'expandwordlist', Read) then do
do while eof('file') = 0
line = readln('file')
if upper(word(line, 1)) = upper(shortword) then do
expwords = expwords subword(line, 2)
found = 'yes'
leave
end
end
end
nil = close('file')
if found = 'no' then expwords = expwords shortword
end
PUTFIELD strip(expwords)
exit
delete_word:
arg delw /* ARexx converts all arguments to UPPER :-( */
if open('in', 'expandwordlist', Read) then do
if open('out', 't:' || 'expandwordlist', Write) then do
do while eof('in') = 0
line = readln('in')
if line ~= '' then
if upper(word(line, 1)) ~= delw then nil = writeln('out', line)
end
nil = close('out')
end
nil = close('in')
end
if open('in', 't:' || 'expandwordlist', Read) then do
if open('out', 'expandwordlist', Write) then do
do while eof('in') = 0
line = readln('in')
if line ~= '' then
nil = writeln('out', line)
end
nil = close('out')
end
nil = close('in')
end
return